# 读取三点坐标到 (xA,yA,zA), (xB,yB,zB), (xC,yC,zC)
execute store result score xA mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in1] Pos[0]
execute store result score yA mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in1] Pos[1]
execute store result score zA mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in1] Pos[2]

execute store result score xB mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in2] Pos[0]
execute store result score yB mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in2] Pos[1]
execute store result score zB mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in2] Pos[2]

execute store result score xC mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in3] Pos[0]
execute store result score yC mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in3] Pos[1]
execute store result score zC mt_surf_fill run data get entity @e[limit=1,tag=mt_surf_fill_in3] Pos[2]

# 计算 a, b, c

# 计算 a
scoreboard players operation surf_a mt_surf_fill = yB mt_surf_fill
scoreboard players operation surf_a mt_surf_fill -= yA mt_surf_fill
scoreboard players operation t2 mt_surf_fill = zC mt_surf_fill
scoreboard players operation t2 mt_surf_fill -= zA mt_surf_fill
scoreboard players operation t3 mt_surf_fill = yC mt_surf_fill
scoreboard players operation t3 mt_surf_fill -= yA mt_surf_fill
scoreboard players operation t4 mt_surf_fill = zB mt_surf_fill
scoreboard players operation t4 mt_surf_fill -= zA mt_surf_fill

scoreboard players operation surf_a mt_surf_fill *= t2 mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= t4 mt_surf_fill

scoreboard players operation surf_a mt_surf_fill -= t3 mt_surf_fill

# 计算 b
scoreboard players operation surf_b mt_surf_fill = zB mt_surf_fill
scoreboard players operation surf_b mt_surf_fill -= zA mt_surf_fill
scoreboard players operation t2 mt_surf_fill = xC mt_surf_fill
scoreboard players operation t2 mt_surf_fill -= xA mt_surf_fill
scoreboard players operation t3 mt_surf_fill = zC mt_surf_fill
scoreboard players operation t3 mt_surf_fill -= zA mt_surf_fill
scoreboard players operation t4 mt_surf_fill = xB mt_surf_fill
scoreboard players operation t4 mt_surf_fill -= xA mt_surf_fill

scoreboard players operation surf_b mt_surf_fill *= t2 mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= t4 mt_surf_fill

scoreboard players operation surf_b mt_surf_fill -= t3 mt_surf_fill

# 计算 c
scoreboard players operation surf_c mt_surf_fill = xB mt_surf_fill
scoreboard players operation surf_c mt_surf_fill -= xA mt_surf_fill
scoreboard players operation t2 mt_surf_fill = yC mt_surf_fill
scoreboard players operation t2 mt_surf_fill -= yA mt_surf_fill
scoreboard players operation t3 mt_surf_fill = xC mt_surf_fill
scoreboard players operation t3 mt_surf_fill -= xA mt_surf_fill
scoreboard players operation t4 mt_surf_fill = yB mt_surf_fill
scoreboard players operation t4 mt_surf_fill -= yA mt_surf_fill

scoreboard players operation surf_c mt_surf_fill *= t2 mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= t4 mt_surf_fill

scoreboard players operation surf_c mt_surf_fill -= t3 mt_surf_fill

# 计算 d
scoreboard players set surf_d mt_surf_fill 0
scoreboard players operation t1 mt_surf_fill = surf_a mt_surf_fill
scoreboard players operation t1 mt_surf_fill *= xA mt_surf_fill

scoreboard players operation t2 mt_surf_fill = surf_b mt_surf_fill
scoreboard players operation t2 mt_surf_fill *= yA mt_surf_fill

scoreboard players operation t3 mt_surf_fill = surf_c mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= zA mt_surf_fill

scoreboard players operation surf_d mt_surf_fill -= t1 mt_surf_fill
scoreboard players operation surf_d mt_surf_fill -= t2 mt_surf_fill
scoreboard players operation surf_d mt_surf_fill -= t3 mt_surf_fill

# 计算 a^2 + b^2 + c^2
scoreboard players operation t1 mt_surf_fill = surf_a mt_surf_fill
scoreboard players operation t1 mt_surf_fill *= surf_a mt_surf_fill

scoreboard players operation t2 mt_surf_fill = surf_b mt_surf_fill
scoreboard players operation t2 mt_surf_fill *= surf_b mt_surf_fill

scoreboard players operation t3 mt_surf_fill = surf_c mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= surf_c mt_surf_fill

scoreboard players operation left mt_surf_fill = t1 mt_surf_fill
scoreboard players operation left mt_surf_fill += t2 mt_surf_fill
scoreboard players operation left mt_surf_fill += t3 mt_surf_fill